/**
Company: Sarkar software technologys
WebSite: http://www.sarkar.cn
Author: yeganaaa
Date : 7/5/18
Time: 4:55 PM
 */

package Cn.Sarkar.MMS.LayerOne.Repositories.Interfaces

data class RepositoryResult<RESULT>(var error: Boolean = false, var exception: Exception?, var result: RESULT?)

fun <RESULT> IRepository.tryExecute(action: () -> RESULT) : RepositoryResult<RESULT>{
    val result =RepositoryResult<RESULT>(true, null, null)
    try {
        result.result = action()
        result.error = false
    }
    catch (exception: Exception){
        result.error = true
        result.exception = exception
    }
    return result
}